       class-id. SnippetOptions as "Barbarian.SnippetOptions".

       environment division.
       configuration section.
       repository.
           class Path         as "System.IO.Path"
           class Application  as "System.Windows.Forms.Application"
           class XmlDocument  as "System.Xml.XmlDocument"
           class XmlElement   as "System.Xml.XmlElement"
           class XmlNode      as "System.Xml.XmlNode"
           class XmlNodeList  as "System.Xml.XmlNodeList"
           .
           
       factory.
       data division.
       procedure division.

       method-id. "CreateNew" internal.
       linkage section.
       01  s         string.
       01  options   object reference active-class.
       procedure division using s returning options.

           invoke self::"New"() returning options.
           invoke options::"Initialize"(s)

       end method "CreateNew".

       method-id. get property "OptionsFile" is public.
       working-storage section.
       01  exe  string value Application::"ExecutablePath".
       01  dir  string value Path::"GetDirectoryName"(exe).
       procedure division returning result as string.

           set result to Path::"Combine"(dir, "BarbarianOptions.xml")

       end method.

       method-id. "LoadAvailableOptions" is public.
       working-storage section.
       01  list     type "System.Collections.Generic.List"[SnippetOptions]
                    value new type "System.Collections.Generic.List"[SnippetOptions].
       01  doc      XmlDocument value new XmlDocument.
       01  nodes    type "System.Xml.XmlNodeList".
       01  i        binary-long.
       linkage section.
       01  result  type "System.Collections.Generic.IEnumerable"[SnippetOptions].
       procedure division returning result.
       
           invoke doc::"Load"(self::"OptionsFile")

*          Behold the COBOL equivalent of a C# foreach loop:
           
           set nodes to doc::"DocumentElement"::"GetElementsByTagName"("SnippetOptions")

           set i to 0
           perform with test before until i = nodes::"Count"
               invoke list::"Add"(SnippetOptions::"FromXmlElement"(nodes::"Item"(i) as XmlElement))
               add 1 to i
           end-perform
           
           set result to list as type "System.Collections.Generic.IEnumerable"[SnippetOptions].
           
       end method "LoadAvailableOptions".

       method-id. "FromXmlElement" is public.
       working-storage section.
       01  nameNode   XmlNode.
       01  valueNode  XmlNode.
       01  tags       XmlNodeList.
       01  tag        XmlNode.
       01  i          binary-long.
       linkage section.
       01  element  XmlElement.
       01  result   SnippetOptions.
       procedure division using element returning result.
 
           set nameNode to element::"Attributes"::"GetNamedItem"("name")
           set result to SnippetOptions::"CreateNew"(nameNode::"Value")
           
           set tags to element::"GetElementsByTagName"("Assembly")
           
           set i to 0
           perform with test before until i = tags::"Count"
               set tag to tags::"Item"(i)
               set nameNode to tag::"Attributes"::"GetNamedItem"("name")
               invoke result::"Assemblies"::"Add"(nameNode::"Value")
               add 1 to i
           end-perform
 
           set tags to element::"GetElementsByTagName"("Namespace")
           
           set i to 0
           perform with test before until i = tags::"Count"
               set tag to tags::"Item"(i)
               set nameNode to tag::"Attributes"::"GetNamedItem"("name")
               invoke result::"Namespaces"::"Add"(nameNode::"Value")
               add 1 to i
           end-perform
           
           set tags to element::"GetElementsByTagName"("CompilerOption")
           
           set i to 0
           perform with test before until i = tags::"Count"
               set tag to tags::"Item"(i)
               set nameNode to tag::"Attributes"::"GetNamedItem"("name")
               set valueNode to tag::"Attributes"::"GetNamedItem"("value")
               set result::"CompilerOptions"::"Item"(nameNode::"Value") to valueNode::"Value"
               add 1 to i
           end-perform
           
       end method "FromXmlElement".

       end factory.
       
*-------------------------------------------------------------------------------
       
       object.
       data division.
       working-storage section.
       01  _name             string.
       01  _namespaces       type "System.Collections.Generic.List"[string]
                             value new "System.Collections.Generic.List"[string].
       01  _assemblies       type "System.Collections.Generic.List"[string]
                             value new "System.Collections.Generic.List"[string].
       01  _compilerOptions  type "System.Collections.Generic.Dictionary"[string, string]
                             value new "System.Collections.Generic.Dictionary"[string, string].
       
       procedure division.      

       method-id. get property "Name" is public.
       procedure division returning result as string.

           set result to _name.

       end method.

       method-id. get property "Namespaces" is public.
       linkage section.
       01  result  type "System.Collections.Generic.IList"[string].
       procedure division returning result.

           set result to _namespaces.

       end method.

       method-id. get property "Assemblies" is public.
       linkage section.
       01  result  type "System.Collections.Generic.IList"[string].
       procedure division returning result.

           set result to _assemblies.

       end method.

       method-id. get property "CompilerOptions" is public.
       linkage section.
       01  result  type "System.Collections.Generic.IDictionary"[string, string].
       procedure division returning result.

           set result to _compilerOptions.

       end method.

       method-id. "Initialize" is private.
       procedure division using s as string.

           set _name to s

       end method "Initialize".

       end object.
       end class SnippetOptions.
